<template>
    <view class='bargain-list' >
		<view class='iconfont icon-xiangzuo' @tap='goBack' :style="'top:'+navH/2+'rpx'"></view>
		<view class='header'>
			
				<img   :src="activityBanner.src" alt="">
				<!--轮播 ，专区 -->
				<!-- <view class="banner">
					<swiper class="screen-swiper square-dot" indicator-dots="true" circular="true"  :autoplay="autoplay" interval="5000" duration="500">
						<swiper-item v-for="(item,index) in bannerList" :key="index"  @click.stop="toBannerUrl(item.miniProgramPath)">
							<image :src="item.src" mode="aspectFill"></image>
							
							<video :src="item.src" controls='true' @play='play' @pause='pause'	 	enable-play-gesture="true"  autoplay  v-if="item.type == 'video'"></video>
							
						</swiper-item>
					</swiper>
				</view> -->
			
		</view>
		
		
		
		<view class='list' v-for="item in data.list"  @click="openSubscribe(item.id)">
			<!-- <block     > -->
				<view  class='item acea-row row-between-wrapper' hover-class='none' >
				<view class='pictrue'>
					<image :src='item.cover_image'></image>
					<view class="sale_count">已售{{item.sale_count}}</view>
				</view>
				<view class='text acea-row row-column-around'>
					<view class='line1'>{{item.name}}</view>
					<!-- <view class='num'><text class='iconfont icon-pintuan'></text></view> -->
					<view class="price-item">
						<!-- <view class='pictrue'></view> -->
						<view class='money font-color '><font>￥</font><text class='price'>{{item.price}}</text></view>
						<!-- <view class='money font-color'><text class='cost_price'>￥{{item.cost}}</text></view> -->
						<view class='cutBnt bg-color'  ><text class='iconfont icon-kanjia'></text>立即抢购</view>
					</view>
					<!-- <view class='money font-color'>￥<text class='price'>{{item.price}}</text></view>
					<view class='money font-color'>￥<text class='cost_price'>{{item.cost}}</text></view> -->
				</view>
				<!-- <view class="price-item">
					<view class='cutBnt bg-color'  ><text class='iconfont icon-kanjia'></text>立即抢购</view>
				</view> -->
				
				</view>
			<!-- </block> -->
		</view>
		<view style="height: 80rpx;"></view>
		<uni-popup-vlogin id="popupvLogin" ref="popupvLogin" type="bottom" />
    </view>
	

    
</template>

<script>
   
	import {oss_host} from '@/config/config.js';
	import store from '@/store/index.js';
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
    //获取网络状态
    import {
        mapGetters
    } from 'vuex';
    export default {
        data() {
            return {
                isSelect: false,
                //网络状态
                networkStatus: true,
				OSS_HOST: oss_host,
				title:'',
				color:'#FF7A47',//背景颜色
                //接口数据
                // bargainList:[],
                data:{
                    bargainList:[
						
						
					],
					list:[],
                    page:0,
                    lastPage:0,
					userInfo:{},
                },
				activityBanner:{},
				id:'',
                limit:20,
                loading:false,
                loadend:false,
				topImage:'',
				autoplay:true,//自动播放
                navH:''
            };
        },
        components: {
			uniPopup
        },
        computed: {
            //注册网络状态
            ...mapGetters(['netWorkType','loginStatus'])
        },
        onShow() {
            // this.getList()
        },

        onLoad(e) {
           // console.log('*****e:',e)
		  
		   if( e.title!='undefined'){
			   this.title = e.title
			   uni.setNavigationBarTitle({
			   	title: e.title,
			   })
			   uni.setNavigationBarColor({
			   	// frontColor: '#ffffff',
			   	backgroundColor: '#ffffff',
			   })
			 
		   }
		   if(typeof e.id != 'undefined' ){
			    this.id = e.id
		   }
		  
		   // switch(this.title){
			  //  case '血糖专区':
					// this.topImage = this.oss_host+'img/xuetang.png'
			  //  break;
			  //  case '血压专区':
					// this.topImage = this.oss_host+'img/xueya.png'
			  //  break;
			  //  case '成人用品专区':
					// this.topImage = this.oss_host+'img/chengrenyp.png'
			  //  break;
		   // }
            this.getList();
			
            // this.userInfo=e.detail

        },
		onReachBottom(){
			 // 分页 上拉加载
			 // console.log(this.data.page,this.data.lastPage)
			if (this.data.page >= this.data.lastPage) {
				// console.log(1111111)
				uni.showToast({
					icon: 'none',
					title: '没有更多数据'
				});
				return;
			}
		  
		  this.getList();
		  
		},
        methods: {
            // 刷新的方法
            refresh() {
                this.getList()
            },
             goBack(){
                uni.navigateBack({ delta: 1 })
              },
			  play(){
			  	this.autoplay=false
			  },
			  pause(){
			  	this.autoplay=true
			  },
            getList(){
                let that = this;
				let is_hot = 1
				let property = ''
				if(this.title == '每日特价'){
					is_hot = 1
				}
				
                 var opt = {
                    url: '/product/getActivityList',
                    data:{
                        page:++that.data.page,
						temp_id:that.id,
						// property_id:property,
						is_hot:is_hot
                    },
                    success: function(res) {
                        console.log(res)
						that.activityBanner = res.data.banner,
						that.color = res.data.backgroundColor?res.data.backgroundColor:'#FF7A47'
						console.log(that.activityBanner,'******banner')
                        if (res.status == 1) {

                            that.data.list=that.data.list.concat(res.data.list)
                            that.data.page=res.data.page
                            that.data.lastPage = res.data.last_page
							// that.data.userInfo = res.data.userInfo
							
							
							
						} else {
                            uni.showToast({
                                icon: 'none',
                                title: res.message
                            });
                        }

                    }
                };
                that.$service.GetApi(opt)




              },
           
           
            openSubscribe(id){
				const _this = this
				if(!_this.loginStatus){
					_this.$refs.popupvLogin.open()
					return
				}
				// console.log(23)
				_this.$refer.setVilit('/pages/GoodsDetails/GoodsDetails')
				let callback = function(url) {
				    // _this.$refs.popupvLogin.open()
				}
				var data = {
				    id: id, //
					// bargainUid:_this.data.userInfo.id,
					
				}
				_this.$refer.toUrl(callback, data)
            },
            
			
			
        }
    }
</script>

<style lang="scss">
    @import "./index.scss";
	
</style>
